#!/bin/zsh

num=20
hisfile=~/.zsh_history
if [ $# -eq 0 ] ; then
    tail -n 20  $hisfile |awk '{if(sub(/^: [0-9]+:[0-9]+;/,"")) print $0}'
else
    cat $hisfile |awk '{if(sub(/^: [0-9]+:[0-9]+;/,"")) print $0}' |grep --color=always $1 
    num=$(cat $hisfile |grep $1 |wc -l)
fi

echo 
echo "result total: $num"

